home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / jpl_c.zip / TOBASE.C < prev    next >
Text File  |  1988-08-06  |  768b  |  28 lines

  1. /* 1.0  01-08-86                         (tobase.c)
  2.  ************************************************************************
  3.  *            Robert C. Tausworthe                *
  4.  *            Jet Propulsion Laboratory            *
  5.  *            Pasadena, CA 91009        1986        *
  6.  ************************************************************************/
  7.  
  8. #include "defs.h"
  9. #include "stdtyp.h"
  10.  
  11. /************************************************************************/
  12.     METACHAR
  13. tobase(c, b)        /* Return value of character c to base b, if
  14.                valid, or EOF if not.            */
  15. /*----------------------------------------------------------------------*/
  16. {
  17.     int n;
  18.  
  19.     if (isdigit(c = tolower(c)))
  20.         c -= '0';
  21.     else if (isalpha(c))
  22.         c -= 'W';    /* 'W' is 'a' - 10    */
  23.     else
  24.         return EOF;
  25.  
  26.     return (c < b ? c : EOF);
  27. }
  28.